// 引入axios用户自定义模块发送请求
import axios from './common.js'

export const login = (logindata) => {
  return axios.post('login', logindata)
}
export const getUsers = (data) => {
  // console.log(data)
  return axios.get('users', { params: data })
}
export const askAddNewUser = (data) => {
  return axios({
    url: 'users',
    method: 'post',
    data
  })
}
// 删除用户数据
export const delUserById = (id) => {
  return axios({
    url: `users/${id}`,
    method: 'delete'
  })
}
// 编辑用户数据
export const editUserById = (data) => {
  return axios({
    url: `users/${data.id}`,
    method: 'put',
    data
  })
}
// 修改用户状态
export const updateUserState = (uld, type) => {
  return axios({
    url: `users/${uld}/state/${type}`,
    method: 'put'
  })
}
// 修改用户角色
export const configureUserRole = (id, rid) => {
  return axios({
    url: `users/${id}/role`,
    method: 'put',
    data: { rid }
  })
}
